package com.bii.gelapp;

import java.io.File;

import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class StartActivity extends Activity {
	Button btDna, btProtein, btMarker;
	public static MarkerStandard ms;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.startactivity);
		
		//to show dialog
		//BrightnessDialog brightdialog = new BrightnessDialog(this, ivImage);
		//brightdialog.show();
		//break;
		btDna = (Button)findViewById(R.id.btDna);
		btProtein = (Button)findViewById(R.id.btProtein);
		btMarker = (Button)findViewById(R.id.btMarker);
		final String btdnatext = btDna.getText().toString();
		final String btProteintext = btProtein.getText().toString();
		btDna.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent gotonextactivity = new Intent(StartActivity.this,
						CropImageActivity.class);
				String origin = "DNA";
				gotonextactivity.putExtra("analysisorigin", "DNA");
				startActivity(gotonextactivity);
				
			}
		});
		
		btProtein.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				MarkerDialog markerdialog = new MarkerDialog(StartActivity.this, btdnatext);
				markerdialog.show();
			}
		});
		
		btMarker.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent gotonextactivity = new Intent(StartActivity.this,
						MarkerGaborActivity2.class);
				startActivity(gotonextactivity);
			}
		});

		
	}
	
	// device back button to finish activity
		@Override
		public void onBackPressed() {
			new AlertDialog.Builder(StartActivity.this)
					.setTitle("Exit Application")
					.setMessage("Do you want to exit?")
					.setPositiveButton("Yes",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int which) {
									android.os.Process
											.killProcess(android.os.Process.myPid());
									System.exit(0);
									
								}
							})
					.setNegativeButton("No", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {

						}
					}).show();
			// super.onBackPressed();
			super.onDestroy();
		}
		/*
		// this is for opencv manager
				public BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
					@Override
					public void onManagerConnected(int status) {
						switch (status) {
						case LoaderCallbackInterface.SUCCESS:
							// DO YOUR WORK/STUFF HERE
							
							break;
						default:
							super.onManagerConnected(status);
							break;
						}
					}
				};

				// onresume is for the opencv
				@Override
				protected void onResume() {
					super.onResume();
					OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8, this,
							mOpenCVCallBack);
				}
			*/
		
		static {
		    if (!OpenCVLoader.initDebug()) {
		        // Handle initialization error
		    }
		}
		/*
		@Override
		protected void onResume() {
			super.onResume();
			//OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8, this,
			//		mOpenCVCallBack);
		}
		*/
	
}
